package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	EmpEventNew           = "erp.EmpNew"
	EmpEventBeforeCreate  = "erp.EmpBeforeCreate"
	EmpEventBeforeUpdate  = "erp.EmpBeforeUpdate"
	EmpEventBeforeSave    = "erp.EmpBeforeCreate erp.EmpBeforeUpdate"
	EmpEventAfterCreate   = "erp.EmpAfterCreate"
	EmpEventAfterUpdate   = "erp.EmpAfterUpdate"
	EmpEventAfterSave     = "erp.EmpAfterCreate erp.EmpAfterUpdate"
	EmpEventDelete        = "erp.EmpDelete"
	EmpAccessControlEvent = "erp.EmpAccessControl"
)

func GetEmpConfig() *mgo.DocConfig {
	return Emp_Config
}

var Emp_Config *mgo.DocConfig

func init() {
	Emp_Config = NewEmpConfig()
}
func NewEmpConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "erp.Emp",
		Fields: []string{
			"name", "code", "department", "phone", "mail", "wechat", "qq",
		},
		RelationFields: []string{
			"department",
		},
		RelationConfigs: map[string]*mgo.DocRelation{
			"department": {
				Config:     GetDepartmentConfig,
				DocName:    "Department",
				JoinType:   "O",
				KeyInside:  "departmentId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
